package com.zhoum.multiconndb.service;

import com.zhoum.multiconndb.model.mysql.Task;
import com.zhoum.multiconndb.model.oracle.Dict;
import com.zhoum.multiconndb.repository.mysql.TaskRepository;
import com.zhoum.multiconndb.repository.oracle.DictRepository;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class MultiSourceServiceImpl implements MultiSourceService{

    @Resource
    TaskRepository taskRepository;
    @Resource
    DictRepository dictRepository;

    @Override
    public Map<String, Object> getList() {
        Task task=new Task();
        task.setIsCron(true);
        task.setDisabled(false);
        Example<Task> taskExample=Example.of(task);
        List<Task> taskList=taskRepository.findAll(taskExample);

        List<Dict> dictList=dictRepository.findAll();

        Map<String,Object> maps=new HashMap<>(2);
        maps.put("tasks",taskList);
        maps.put("dicts",dictList);

        return maps;
    }
}
